<?php
/**
 * @description : The third-party Login select page.
 * @author      : stephen.mo
 * @date        : Oct 8,2010
 */
require_once "TVB/OAuth/common.inc.php";
#ini_set('display_errors','on');

$oauth_token        = (isset($_REQUEST['oauth_token'])) ? $_REQUEST['oauth_token'] : NULL;
$real_call_back     = (isset($_REQUEST['oauth_callback'])) ? $_REQUEST['oauth_callback'] : NULL;
$lang               = (isset($_REQUEST['lang'])) ? OAuthUtils::chkLang($_REQUEST['lang']) : OAuthConfig::DEFAULT_SUPPORT_LANG;

//path setting.
$base_server_path   = OAuthConfig::OAuthDomainUrl($_SERVER);
$current_reback_url = $base_server_path.OAuthConfig::DEFAULT_AUTO_AUTHORIZE;
$real_login_url     = $base_server_path.OAuthConfig::DEFAULT_AUTHORIZE_URL;
$jqtouch_url        = $base_server_path.OAuthModelConfig::DEFAULT_MOBILE_TEMPLATE;
$default_header     = $base_server_path.OAuthConfig::DEFAULT_HEADER_URL;

$base_back_string   = '?lang='.$lang.'&oauth_callback='.urlencode($real_call_back).'&oauth_token='.$oauth_token;
$callback_urls      = $current_reback_url.$base_back_string;
$reback_url         = $real_login_url.$base_back_string;
$back_url           = $default_header.'?oauth_reback='.urlencode($reback_url); 
$suffix_href_url    = '?oauth_callback='.urlencode($callback_urls);

//get third-parties login list.
$third_items        = OAuthUtils::getThirdPartiesList();

//page info vars
$third_party_info   = OPI::$third_party_info;
$payment_buttons    = OPI::$payment_button_info;

//setting the form datas into array
$form = array();
$using_real_env     = OAuthModelConfig::USING_TEMPLATE_ON_REAL_ENV;
$page               = OAuthModelConfig::M_PAGE_OF_THIRDP_LOGIN; 

$form['lang']             = $lang;
$form['title']            = $third_party_info[$lang]['page_title'];
$form['action']           = NULL;
$form['method']           = 'POST';
$form['thirdlogin_title'] = $third_party_info[$lang]['thirdlogin_title'];
$form['button']['cancel'] = array('value'=>$payment_buttons[$lang]['back'],'link'=>$back_url);
$form['thirdlogin_items'] = $third_items;
$form['error_msg']        = (empty($third_items)) ? OPI::$error_page_info[$lang]['error_no_thirdlist'] : NULL;

//include this template for forget password page.
include "..".OAuthModelConfig::DEFAULT_MOBILE_TEMPLATE.OAuthModelConfig::$mobile_teplate_page[$page];

?>
